package org.zn.mvcbase.exception;

import java.io.IOException;
import java.util.Map;

import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.web.servlet.ModelAndView;

/**  
*  
* @author 周楠
* @Description: 
*
* @date 2017年9月4日
*
*/
public class ApplicationJsonResponseState  extends AbstractResponseHandlerState{

	/* (non-Javadoc)
	 * @see org.zn.mvcbase.exception.ExceptionResponseState#exceptionResponse(java.util.Map)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public ModelAndView exceptionResponse(Map<String, Object> exMessage) {
		
       exMessage.remove(ExceptionResponseMessage.ERRORPAGE_KEY);
		
		try {
			HttpMessageConverter<Map<String, Object>> hmc= (HttpMessageConverter<Map<String, Object>>) converterMap.get("jsonConverter");
			hmc.write(exMessage,MediaType.APPLICATION_JSON, outputMessage);
		} catch (HttpMessageNotWritableException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
